home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Science / RLaB / help / INTRO < prev    next >
Text File  |  1994-04-25  |  8KB  |  244 lines

  1. INTRO:
  2.  
  3.     Introduction to RLaB  "Our"-LaB.
  4.  
  5.     RLaB is a vector and matrix oriented, interactive, interpreted
  6.     programming LANGUAGE. Although RLaB started as an effort to
  7.     functionally replace MATLAB, the language and functions are
  8.     NOT MATLAB replicas. Although the language is similar to
  9.     MATLAB in some ways there are numerous differences (I hope for
  10.     the better). The help file MATLAB_DIFF briefly discusses the
  11.     primary differences between RLaB and MATLAB. If you are a
  12.     MATLAB expert please read the MATLAB_DIFF file ASAP.
  13.  
  14.     The RLaB Primer is also a good starting point for new users.
  15.     It is short, and provides many introductory examples.
  16.  
  17.     Using RLaB:
  18.  
  19.     To get this far you must already be running RLaB. At this
  20.     point you are using the command line interface. When RLaB
  21.     confronts you with the command line prompt (`>') it is ready
  22.     to accept any valid statement. As soon as a valid statement is
  23.     recognized, RLaB will execute it. For example
  24.  
  25.     > a = sqrt(2)
  26.      a =
  27.          1.41
  28.  
  29.     The right-hand-side (RHS) of the expression is evaluated, and
  30.     the result is assigned to `a' immediately.
  31.  
  32.     There are several data types. You do NOT need to declare
  33.     variable types, just use them (the variable(s)) in the proper
  34.     context. In the previous example `a' was a scalar. In the
  35.     following example `a' will be used as a matrix:
  36.  
  37.     > a = [1,2,3;4,5,6;7,8,9]
  38.      a =
  39.      matrix columns 1 thru 3
  40.                1           2           3
  41.                4           5           6
  42.                7           8           9
  43.  
  44.     The previous example created a matrix and stored it in the
  45.     variable (entity) `a'. The previous entity that `a'
  46.     represented (sqrt(2)) is destroyed.
  47.  
  48.     You can use most math operators like you would in C:
  49.  
  50.     a + b        Addition
  51.     a - b        Subtraction
  52.     a * b        Matrix Multiplication
  53.     a .* b        Matrix element-by-element multiply
  54.     a / b        Right Division
  55.     a ./ b        Element-by-element Right Division
  56.     a \ b        Left Division
  57.     a .\ b        Element-by-element Left Division
  58.     a^b        Power
  59.     a.^b        Element-by-element power
  60.     -a        Unary minus (negation)
  61.     +a        Unary plus 
  62.     a'        Matrix transpose (Hermitian transpose)
  63.     a.'        Matrix element-by-element transpose
  64.  
  65.     To see all of the available functions type `what()'. Try using
  66.     some:
  67.  
  68.     > what()
  69.     abs           diag          int           pause         solve         
  70.     acos          diary         int2str       pclose        sort          
  71.     acosh         diff          intersection  phrd          sprintf       
  72.     all           disp          inv           plot          sqrt          
  73.     any           dot           isempty       printf        srand         
  74.     asin          eig           isinf         printmat      std           
  75.     asinh         epsilon       isnan         prod          strsplt       
  76.     atan          error         issymm        qr            sum           
  77.     atan2         eval          length        rand          svd           
  78.     atanh         exist         linspace      rank          sylv          
  79.     backsub       exp           load          rcond         symm          
  80.     balance       eye           log           read          system        
  81.     cd            factor        log10         readm         tan           
  82.     ceil          fft           logspace      real          tanh          
  83.     chol          find          lu            redit         tic           
  84.     class         finite        lyap          reshape       tmp_file      
  85.     clear         fix           matrix        round         toc           
  86.     clearall      floor         max           save          trace         
  87.     close         format        maxi          scalar        tril          
  88.     compan        fprintf       mean          schur         triu          
  89.     complement    fvscope       members       set           type          
  90.     conj          getline       min           setterm       union         
  91.     cos           hess          mini          show          what          
  92.     cosh          hilb          mod           showplot      who           
  93.     cross         ifft          nan           sign          whos          
  94.     cumprod       imag          norm          sin           write         
  95.     cumsum        inf           num2str       sinh          writem        
  96.     det           input         ones          size          zeros         
  97.  
  98.      1st enter a matrix:
  99.  
  100.     > a = [1,2,3;4,5,6;7,8,9]
  101.      a =
  102.      matrix columns 1 thru 3
  103.                1           2           3
  104.                4           5           6
  105.                7           8           9
  106.     
  107.     Then transpose it:
  108.  
  109.     > b = a'
  110.      b =
  111.      matrix columns 1 thru 3
  112.                1           4           7
  113.                2           5           8
  114.                3           6           9
  115.  
  116.     Then perform matrix multiplication with the two matrices:
  117.  
  118.     > c = a * b
  119.      c =
  120.      matrix columns 1 thru 3
  121.               14          32          50
  122.               32          77         122
  123.               50         122         194
  124.  
  125.     Do an element - by - element multiply:
  126.  
  127.     > d = a .* b
  128.      d =
  129.      matrix columns 1 thru 3
  130.                1           8          21
  131.                8          25          48
  132.               21          48          81
  133.  
  134.     Zero out the element of a that is in the 3rd row, 3rd column.
  135.  
  136.     > a[3;3] = 0
  137.      a =
  138.      matrix columns 1 thru 3
  139.                1           2           3
  140.                4           5           6
  141.                7           8           0
  142.  
  143.     Use det() to compute the value of the determinant of [a].
  144.  
  145.     > det(a)
  146.               27
  147.  
  148.     Use another built-in function to estimate the reciprocal of
  149.     the condition number:
  150.  
  151.     > rcond(a)
  152.          0.01935
  153.     > 1/rcond(a)
  154.            51.67
  155.     
  156.     Use another built-in function to compute the matrix inverse:
  157.  
  158.     > inv(a)
  159.      matrix columns 1 thru 3
  160.           -1.778      0.8889     -0.1111
  161.            1.556     -0.7778      0.2222
  162.          -0.1111      0.2222     -0.1111
  163.  
  164.     Use yet another to compute the eigenvalues, and eigenvectors
  165.     of [a]:
  166.  
  167.     > eig( [1,2,3;4,5,6;7,8,9] )
  168.        val          vec          
  169.  
  170.     Notice that eig() appears to return two variables, val, and
  171.     vec. Actually eig() returns a LIST. A LIST is an entity that
  172.     contains other entities. Functions that need to return more
  173.     than one entity do so via a LIST. See `help LIST' if LISTs are
  174.     confusing you.
  175.  
  176.     The members of a list are accessed via a special syntax.
  177.  
  178.     list . lname
  179.  
  180.     will reference the member of the list with a name equal to
  181.     lname. For example:
  182.  
  183.     > eig([1,2,3;4,5,6;7,8,9]).val
  184.      val =
  185.      matrix columns 1 thru 3
  186.                    16.1 + 0i              -1.12 + 0i          -8.46e-16 + 0i
  187.  
  188.     will return the eigenvalues of the input. If you want to save
  189.     the entire list, then save it in a variable.
  190.  
  191.     > a = eig([1,2,3;4,5,6;7,8,9])
  192.        val          vec          
  193.  
  194.     Then you can access the members of the list:
  195.  
  196.     > a.val
  197.      val =
  198.      matrix columns 1 thru 3
  199.                    16.1 + 0i              -1.12 + 0i          -8.46e-16 + 0i
  200.     
  201.     > a.vec
  202.      vec =
  203.      matrix columns 1 thru 3
  204.                   0.232 + 0i              0.786 + 0i              0.408 + 0i
  205.                   0.525 + 0i             0.0868 + 0i             -0.816 + 0i
  206.                   0.819 + 0i             -0.612 + 0i              0.408 + 0i
  207.     
  208.     If you want to know what the names of the list members are you
  209.     can simply type the list variable at the prompt:
  210.  
  211.     > a
  212.        val          vec          
  213.  
  214.     Or, you can use the members function:
  215.  
  216.     > members(a)
  217.     val  vec  
  218.  
  219.     To see what variables are in the workspace, type `who()'
  220.  
  221.     > who()
  222.     a      c      pi                          
  223.     b      d      pinfo                       
  224.  
  225.     A variable can be removed from the workspace, and it's memory
  226.     freed, with the clear function:
  227.  
  228.     > clear(a, d)
  229.                2
  230.     > who()
  231.     b      c      pi     pinfo  
  232.  
  233.     Clear returns a number that signifies how many objects were
  234.     cleared from the workspace.
  235.  
  236.     At this point you should be starting to get an idea of some of
  237.     the things RLaB can do, even though we have not yet introduced
  238.     logical operators, conditional statements, looping statements,
  239.     and user-functions.
  240.  
  241.     Please skim through all the help files that are spelled with
  242.     capital letters. This will acquaint you with more features and
  243.     let you know where to go for help in the future.
  244.